package com.bingxue.edu.management.report.controller;

import com.bingxue.edu.framework.common.model.Response;
import com.bingxue.edu.framework.common.util.ValidationUtils;
import com.bingxue.edu.framework.security.ApiResource;
import com.bingxue.edu.management.report.model.query.LessonStatQuery;
import com.bingxue.edu.management.report.model.resp.LessonStatListResp;
import com.bingxue.edu.management.report.model.resp.LessonStatReportResp;
import com.bingxue.edu.management.report.service.LessonStatService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 课消统计
 * @author panbo
 * @since 2024/12/30
 */
@Slf4j
@Tag(name = "课消统计接口")
@RestController
@RequestMapping("/report/lesson")
@RequiredArgsConstructor
public class LessonStatReportController {

    private final LessonStatService lessonStatService;

    @Operation(summary = "课消统计")
    @ApiResource("report:lesson:stat")
    @GetMapping("/stat")
    public Response<List<LessonStatReportResp>> getLessonStatReport(@Validated LessonStatQuery query) {
        return Response.success(lessonStatService.getLessonStatReport(query));
    }

    @Operation(summary = "课消明细")
    @ApiResource("report:lesson:stat")
    @GetMapping("/list")
    public Response<List<LessonStatListResp>> getLessonStatList(@Validated LessonStatQuery query) {
        ValidationUtils.throwIfEmpty(query.getId(), "班级id不能为空");
        return Response.success(lessonStatService.getLessonStatList(query));
    }
}
